/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ep.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Spyros
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@Entity
@Table(name = "t010_substance", catalog = "epresc", schema = "")
@NamedQueries({
    @NamedQuery(name = "T010Substance.findAll", query = "SELECT t FROM T010Substance t"),
    @NamedQuery(name = "T010Substance.findById", query = "SELECT t FROM T010Substance t WHERE t.id = :id"),
    @NamedQuery(name = "T010Substance.findByCode", query = "SELECT t FROM T010Substance t WHERE t.code = :code"),
    @NamedQuery(name = "T010Substance.findByName", query = "SELECT t FROM T010Substance t WHERE t.name = :name")})
public class T010Substance implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "t010Substance")
    private Collection<T011Interaction> t011InteractionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "t010Substance1")
    private Collection<T011Interaction> t011InteractionCollection1;
    @ManyToMany(mappedBy = "t010Substances")
    private Collection<T007Illness> t007Illnesses;
    @ManyToMany(mappedBy = "t010Substances")
    private Collection<T009Medicine> t009Medicines;


    public T010Substance() {
    }

    public T010Substance(Integer id) {
        this.id = id;
    }

    public T010Substance(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Collection<T011Interaction> getT011InteractionCollection() {
        return t011InteractionCollection;
    }

    public void setT011InteractionCollection(Collection<T011Interaction> t011InteractionCollection) {
        this.t011InteractionCollection = t011InteractionCollection;
    }

    public Collection<T011Interaction> getT011InteractionCollection1() {
        return t011InteractionCollection1;
    }

    public void setT011InteractionCollection1(Collection<T011Interaction> t011InteractionCollection1) {
        this.t011InteractionCollection1 = t011InteractionCollection1;
    }

    @XmlTransient
    public Collection<T007Illness> getT007Illnesses() {
        return t007Illnesses;
    }
    
    public void setT007Illnesses(Collection<T007Illness> t007Illnesses) {
        this.t007Illnesses = t007Illnesses;
    }

    @XmlTransient
    public Collection<T009Medicine> getT009Medicines() {
        return t009Medicines;
    }

    public void setT009Medicines(Collection<T009Medicine> t009Medicines) {
        this.t009Medicines = t009Medicines;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof T010Substance)) {
            return false;
        }
        T010Substance other = (T010Substance) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name;
    }

}
